// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import routes from './routes';
const TerserPlugin = require('terser-webpack-plugin')

const { REACT_APP_ENV } = process.env;

// const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
// const smp = new SpeedMeasurePlugin();

export default defineConfig({
  // exportStatic: {},
  hash: true,
  antd: {},
  dva: {
    hmr: true,
    immer:{enableES5:true}
  },
  history: {
    type: 'hash',
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes,
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    'primary-color': defaultSettings.primaryColor,
  },
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
  base: '/jf/',
  publicPath: '/jf/',
  // chainWebpack:(memo, { webpack }) => {
  //   memo.plugin('TerserPlugin').use(TerserPlugin, [{
  //     parallel: require('os').cpus().length - 1,
  //     terserOptions: {
  //       compress: {
  //         inline: false
  //       },
  //       mangle: {
  //         safari10: true
  //       } 
  //     }
  //   }])
  // },
  // esbuild: {},
});
